/**
 * Class: DVector3
 *
 * Purpose: 
 *
 * Created: Jan 23, 2010 @ 11:06:19 PM
 * @author Ken Scott
 */
package org.openfantasia.util.math;

import org.openfantasia.util.Copyable;

public class DVector3 implements Copyable<DVector3> {

	private static final int N = 3;

	public double p[][][];


	public DVector3() {
		p = new double[N][N][N];
	}


	public DVector3(double[][][] p) {
		if (p[0][0].length != N) {
			throw new IllegalArgumentException("Input array must be of length " + N + ", not " + p[0][0].length);
		}
		this.p = Math3D.copy(p);
	}


	public DVector3(DVector3 p) {
		this(p.p);
	}


	public DVector3 copy() {
		return new DVector3(p);
	}


	public void copy(DVector3 that) {
		p = Math3D.copy(that.p);
	}


	public DVector3 clear() {
		Math3D.fill(p, 0);
		return this;
	}


	public double[][][] getValue() {
		return p;
	}


	public DVector3 mulNoise(double frac) {
		p = Math3D.mulNoise(p, frac);
		return this;
	}


	public DVector3 addNoise(double frac) {
		p = Math3D.addNoise(p, frac);
		return this;
	}


	public DVector3 neg() {
		p = Math3D.neg(p);
		return this;
	}


	public DVector3 abs() {
		p = Math3D.abs(p);
		return this;
	}


	public DVector3 add(DVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.add(p, a.p);
		return this;
	}


	public DVector3 sub(DVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.sub(p, a.p);
		return this;
	}


	public DVector3 mul(DVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.mul(p, a.p);
		return this;
	}


	public DVector3 div(DVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.div(p, a.p);
		return this;
	}
}